home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*
- *
- * menu.c
- *
- */
-
-
- #include <stdio.h>
- #include <gl.h>
- #include "defines.h"
- #include "device.h"
- #include "event.h"
- #include "menu.h"
- #include "control.h"
- #include "nurb.h"
- #include "file.h"
- #include "snurb.h"
-
-
- /* Declare menus */
- static long snurb_menu;
- static long tool_menu;
- static long file_menu;
- static long primitive_menu;
- static long options_menu;
-
- extern int tool;
- extern int primitive;
-
-
- /*
- * Allocate and initialize the menus, then tell the event manager
- * to watch for right mouse button clicks.
- */
- void init_menus(void)
- {
- snurb_menu = newpup();
- tool_menu = newpup();
- file_menu = newpup();
- primitive_menu = newpup();
- options_menu = newpup();
-
- set_defaults();
-
- add_event(ANY, RIGHTMOUSE, DOWN, do_menus, NULL);
- qdevice(RIGHTMOUSE);
- }
-
-
- /*
- * Called by the event manager whenever the right mouse button is
- * pressed.
- */
- void do_menus(void)
- {
- dopup(snurb_menu);
- }
-
-
- /*
- * Rebuild the entire menu tree. Because menu items change based upon
- * user input, sub-menus are rebuilt as necessary. Then the root menu
- * is rebuilt using these chaned sub-menus.
- */
- void remake_snurb_menu(void)
- {
- freepup(snurb_menu);
- snurb_menu = newpup();
-
- addtopup(snurb_menu, "Snurbs %t", 0L); /* title */
- addtopup(snurb_menu, "Tools %m", tool_menu);
- addtopup(snurb_menu, "Options %m", options_menu);
- addtopup(snurb_menu, "File %m", file_menu);
- addtopup(snurb_menu, "Add primitive %l%m", primitive_menu);
- addtopup(snurb_menu, "Group Objects %f", group);
- addtopup(snurb_menu, "Ungroup Objects %l%f", ungroup);
- addtopup(snurb_menu, "Select All Objects %f", select_all);
- addtopup(snurb_menu, "Delete Selected Objects %f", delete_object);
- addtopup(snurb_menu, "Set Defaults %f", set_defaults);
- addtopup(snurb_menu, "Quit Snurb %f", quit);
- }
-
-
- /*
- * Remakes the menu which giving control over the current tool.
- */
- void remake_tool_menu(void)
- {
- char menu_string[32];
-
- freepup(tool_menu);
- tool_menu = newpup();
-
- addtopup(tool_menu, "Tool %t %F", change_tool);
-
- if (tool == MOVE_TOOL)
- sprintf(menu_string, "->Move Tool %%x%d", MOVE_TOOL);
- else
- sprintf(menu_string, " Move Tool %%x%d", MOVE_TOOL);
- addtopup(tool_menu, menu_string, 0L);
-
- if (tool == EDIT_TOOL)
- sprintf(menu_string, "->Edit Tool %%x%d", EDIT_TOOL);
- else
- sprintf(menu_string, " Edit Tool %%x%d", EDIT_TOOL);
- addtopup(tool_menu, menu_string, 0L);
-
- if (tool == SCALE_TOOL)
- sprintf(menu_string, "->Scale Tool %%l%%x%d", SCALE_TOOL);
- else
- sprintf(menu_string, " Scale Tool %%l%%x%d", SCALE_TOOL);
- addtopup(tool_menu, menu_string, 0L);
-
- if (tool == SHARP_ZIP_TOOL)
- sprintf(menu_string, "->Sharp Zip Tool %%x%d", SHARP_ZIP_TOOL);
- else
- sprintf(menu_string, " Sharp Zip Tool %%x%d", SHARP_ZIP_TOOL);
- addtopup(tool_menu, menu_string, 0L);
-
- if (tool == SMOOTH_ZIP_TOOL)
- sprintf(menu_string, "->Smooth Zip Tool %%x%d", SMOOTH_ZIP_TOOL);
- else
- sprintf(menu_string, " Smooth Zip Tool %%x%d", SMOOTH_ZIP_TOOL);
- addtopup(tool_menu, menu_string, 0L);
-
- if (tool == ROUND_ZIP_TOOL)
- sprintf(menu_string, "->Round Zip Tool %%l%%x%d", ROUND_ZIP_TOOL);
- else
- sprintf(menu_string, " Round Zip Tool %%l%%x%d", ROUND_ZIP_TOOL);
- addtopup(tool_menu, menu_string, 0L);
-
- if (tool == UNZIP_TOOL)
- sprintf(menu_string, "->Unzip Tool %%x%d", UNZIP_TOOL);
- else
- sprintf(menu_string, " Unzip Tool %%x%d", UNZIP_TOOL);
- addtopup(tool_menu, menu_string, 0L);
- }
-
-
-
- /* Remakes the options menu, which includes some of the above menus as
- * sub-menus and is itself a sub-menu to the root menu.
- */
- void remake_options_menu(void)
- {
- freepup(options_menu);
- options_menu = newpup();
-
- addtopup(options_menu, "Options %t", 0L);
-
- addtopup(options_menu, "Invert Selected Objects %f", invert_objects);
- addtopup(options_menu, "Set Pixel Tolerance %f", change_tolerance);
- }
-
-
- void remake_file_menu(void)
- {
- freepup(file_menu);
- file_menu = newpup();
-
- addtopup(file_menu, "File %t", 0L);
-
- addtopup(file_menu, "Load /tmp/junk.snb %f", load_file);
- addtopup(file_menu, "Save /tmp/junk.snb %f", save_file);
- }
-
-
-
- void remake_primitive_menu(void)
- {
- char menu_string[32];
-
- freepup(primitive_menu);
- primitive_menu = newpup();
-
- addtopup(primitive_menu, "Primitives %t %F", add_primitive);
-
- sprintf(menu_string, "Plane %%x%d", PLANE);
- addtopup(primitive_menu, menu_string, 0L);
-
- sprintf(menu_string, "Cube %%x%d", CUBE);
- addtopup(primitive_menu, menu_string, 0L);
-
- sprintf(menu_string, "Teapot %%x%d", TEAPOT);
- addtopup(primitive_menu, menu_string, 0L);
-
-
- }
-
- void remake_all_menus()
- {
- remake_tool_menu();
- remake_options_menu();
- remake_file_menu();
- remake_primitive_menu();
- remake_snurb_menu();
- };
-